<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/WEB-INF/struts-tags.tld"%>
<%@ taglib prefix="shiro" uri="/WEB-INF/shiro.tld"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<link id="favicon" href="favicon.ico" rel="icon" type="image/x-icon" />
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>改变头像</title>
<link rel="stylesheet" href="/jxgl/css/all.css" />
<link rel="stylesheet" href="/jxgl/css/login.css" />
<link rel="stylesheet" href="/jxgl/css/list.css" />
<link rel="stylesheet" href="/jxgl/uploadify/uploadify.css" />
<style type="text/css">
#single-column {
	padding: 10px;
	clear: both;
}
#picturenow {
	float: left;
	width: 202px;
	margin: 0 20px 0 20px;
}
#pictureinfuture {
	float: left;
	width: 450px;
}
.clear {
	clear: both;
}
#picturenow h3, #pictureinfuture h3 {
margin: 10px 0;
border-bottom: 1px solid #d8dfea;
line-height: 1.5em;
color: #000;
font-size:14px;
}
.dimage {
padding: 0 10px 10px 10px;
text-align: center;
overflow: hidden;
}
.dimage img {
margin: 0 auto;
max-width: 140px;
height: 140px;
border: 1px solid #ccc;
}
</style>
<script type="text/javascript" src="/jxgl/js/jquery-1.8.0.min.js"></script>
<script type="text/javascript" src="/jxgl/uploadify/jquery.uploadify.min.js"></script>
<script type="text/javascript">
$(function() {
	$("#file_upload").uploadify({
		height		:30,
		swf			:'/jxgl/uploadify/uploadify.swf',
		uploader	:'/jxgl/uploadFile',
		cancelImg	:'/jxgl/uploadify/uploadify-cancel.png',
		multi		:false,
		fileExt		:'*.jpg;*.gif;*.png;',
        fileDesc:	'Image Files (.JPG, .GIF, .PNG)',
        sizeLimit   :1024000,
		width		:120,
		debug		:false,
		successTimeout:99999,
		buttonText	:'选择文件',
		fileObjName :'fileupload',
		onQueueComplete:function(data){
			location.reload();
		}
		
	});
});</script>
</head>
<body id="lg_body">
	<div id="lg_wrap">
		<div id="ln_header">
			<div class="header_logo_bg">
				<div class="header_link"> 
						<a target="_blank" href="http://www.changdajx.cn/%E8%81%94%E7%B3%BB%E6%88%91%E4%BB%AC/"
						class="help_icon">问题咨询</a>&nbsp;&nbsp; 
						<a target="_blank"
						href="http://www.changdajx.cn"
						class="home_icon">驾校首页</a>&nbsp;&nbsp;
				</div>
			</div>
		</div>
		<div class="main_link" style="width: 960px; margin-top: 3px;">
			<a href="/jxgl/login"><b>首页</b></a> &gt; <font color="#666666">更换头像</font>
		</div>
		<div id="ln_main" style="height: 800px; width: 960px;">
			<div id="left-column">
				<div class="widget-alt">
					<div class="headline no-margin">
						<h4>管理工具箱</h4>
					</div>
					<ul class="links-list-alt" style="padding-left: 0px">						
						<shiro:hasRole name="admin">
							<li><a href="/jxgl/login">修改个人信息</a></li>
							<li><a href="/jxgl/changePic.jsp">修改头像</a></li>
							<li><a href="/jxgl/admin/editPwd">修改密码</a></li>
							<li><a href="/jxgl/admin/newdriver.jsp">新建教练</a></li>
							<li><a href="/jxgl/admin/listdriver">教练列表</a></li>
						</shiro:hasRole>
						<shiro:hasRole name="driver">
							<li><a href="/jxgl/login">修改个人信息</a></li>
							<li><a href="/jxgl/changePic.jsp">修改头像</a></li>
							<li><a href="/jxgl/driver/editPwd">修改登录密码</a></li>
							<li><a href="/jxgl/driver/liststudent">我的学生</a></li>
						</shiro:hasRole>
						<shiro:hasRole name="student">
							<li><a href="/jxgl/student/showme">修改个人信息</a></li>
							<li><a href="/jxgl/changePic.jsp">修改头像</a></li>
                            <li><a href="/jxgl/student/editPwd">登录密码</a></li>
                            <li><a href="/jxgl/student/listdriver">选择教练</a></li>
						</shiro:hasRole>
						<li><a href="/jxgl/logout">退出登录</a></li>
					</ul>
				</div>
			</div>
			<div id="center-column">
				<div class="headline no-margin">
					<h4>修改头像</h4>
				</div>
				<div id="single-column">
					<div id="picturenow">
						<h3>当前头像</h3>
						<div class="dimage">
<%
org.apache.shiro.subject.Subject currentUser = org.apache.shiro.SecurityUtils.getSubject();
String avatarpath;
if(currentUser != null){
	Object o = currentUser.getPrincipal();
	if(o instanceof com.tuiyun.jxgl.bean.Student){
		com.tuiyun.jxgl.bean.Student s = (com.tuiyun.jxgl.bean.Student)o;
		
		avatarpath = s.getAvatar();
		System.out.println(avatarpath);
	}else{
		com.tuiyun.jxgl.bean.Driver d = (com.tuiyun.jxgl.bean.Driver) o;
		avatarpath = d.getAvatar();
	}
	if(avatarpath == null){
		out.write("<img src=\"img/noavatar_middle.gif\">");
	}else{
		out.write("<img src=\"download.action?fileName="+avatarpath+"\">");
	}
}
%>							
						</div>
					</div>
					<div id="pictureinfuture">
						<h3>设置新头像</h3>
						<div style="width:400px">
							<div id="preview"></div>
							<p>
								<input type="file" name="fileupload" id="file_upload" />
							</p>
						</div>
					</div>
					<br class="clear">
				</div>
			</div>
		</div>
	</div>
</body>
</html>